
@extends('Home.Index')
@section('男人装官方商城','购物车-男人装官方商城')
@section('Home.Model')
@if(isset($_SESSION['shop']))
<script src="/jquery-1.7.2.js"></script>
    <div id="container" class="page-container clearfix">
      <div class="wrap">
        <div class="bread-crumbs"></div>
        <div id="main">
          <!-- checkout开始 -->
          <div class="cart-title">
            <h1>购物车</h1>
          </div>
          <!-- checkout步骤图 -->
          <div id="cart_steps" class="steps">
            <table width="100%">
              <tbody>
                <tr>
                  <td class="step-item step-1 active">
                    <a href="/cart.html">
                    <q class="icon">1</q>
                    <i>1</i>购物车</a>
                  </td>
                  <td class="icon step-arrow">》</td>
                  <td class="step-item step-2 ">
                    <span>
                    <q class="icon">2</q>
                    <i>2</i>填写和提交订单信息</span>
                  </td>
                  <td class="icon step-arrow">》</td>
                  <td class="step-item step-3">
                    <span>
                    <q class="icon">3</q>
                    <i>3</i>成功提交订单</span>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <!-- checkout主体 -->
          <div id="order_container" class="order-container">
            <div class="title">
              <h2>已选择的商品</h2>
            </div>
            <!-- checkout内容 -->
            <form action="/order" method="post">
            {!!csrf_field()!!}
            <input type="hidden" value=""/>
            <!-- 订单信息填写 -->
            <div id="member_orders" class="member-mod">
                <div class="member-mod-content">
                  <table class="member-grid">
                    <thead>
                      <tr>
                        <th>商品</th>        
                        
                        <th>销售价</th>
                        
                        <th>数量</th>
                        <th>优惠金额</th>
                        <th>小计</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    @foreach($_SESSION['shop'] as $result)
                    <tbody> <!--class="fold first" -->
                      <tr align="center">
                        <td width="28%">
                            &nbsp;<a href="#"><img style="height:80px;width:80px" src="/uploads/{{$result->gimg}}"></a>
                            <span>商品名：{{$result->gname}}</span>
                        </td>
                        
                        <td align="center" class="price">￥{{$result->gprice}}</td>

                        <td align="center" >
                          <span  class="p-quantity">
                            
                            <button id="increat" type="button">+</button>
                            <input  align="center" type="text" size="2" name="goods.num" class="action-quantity-input"  id="input_num" value="{{$result->nnum}}" />
                            <button id="decreat" type="button">-</button>
                          </span>
                        </td>     
                        <td align="center" >￥0.00</td>
                        
                        <td align="center" class="num">￥{{$result->nnum*$result->gprice}}</td>
                        <td class="actions" valign="center">
                            <a href="/member-orderdetail-160618134600673.html">查看订单</a> 
                            <a href="/delshopping/{{$result->gid}}">删除订单</a>
                        </td>
                      </tr>
                    </tbody>
                    <script>
                             //alert($);
                             $(function(){
                               $('#increat').click(function(){
                                
                                 var abc = $('#input_num').val();
                                 if(parseInt(abc) >= {{$result->num}}){
                                   alert('超出库存数量 无法添加');
                                 }else{
                                   $('#input_num').val( parseInt(abc)+1);
                                   $('.num').html('￥'+({{$result->nnum+=1}}*{{$result->gprice}}));
                                 } 
                                      
                               });
                               $('#decreat').click(function(){
                                 var abc = $('#input_num').val();
                                 if(parseInt(abc) <= 1){
                                   alert('该商品的最小购买数量为1件');
                                 }else{
                                   $('#input_num').val( parseInt(abc)-1);
                                   $('.num').html('￥{{($result->nnum-1)*$result->gprice}}')
                                 } 
                               });
                             });
                           </script>
                    @endforeach
                    <tbody align="left"> 
                      <tr align="left">
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td>
                      <td></td> 
                        <td id="order_price" class="order-price">
                          <div class="inner">
                          @if($_SESSION['shop'])
                            <ul>
                              <li class="goods">
                              <span>
                              <span class="label">
                                <h4>商品总金额：</h4>
                              </span> 
                              <span class="price">
                                <h4>￥{{($result->nnum-1)*$result->gprice}}</h4>
                              </span></span></li>

                              <li class="total">
                              <span class="label">
                                <h2><em>总金额：</em></h2>
                              </span> 
                              <span class="price">
                                <h2><b>￥{{($result->nnum-1)*$result->gprice}}</b></h2>
                              </span></li>
                            </ul>
                            @else
                              <ul>
                              <li class="goods">
                              <span>
                              <span class="label">
                                <h4>商品总金额：</h4>
                              </span> 
                              <span class="price">
                                <h4>￥0</h4>
                              </span></span></li>

                              <li class="total">
                              <span class="label">
                                <h2><em>总金额：</em></h2>
                              </span> 
                              <span class="price">
                                <h2><b>￥0</b></h2>
                              </span></li>
                            @endif
                          </div>
                        </td>    
                      </tr>
                    </tbody>
                    <thead>
                      <tr>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th><button type="button"><a href="/">继续购物</a></button></th>        
                        <th><button type="button" id="clearCar"><a href="/delshopping/0">清空购物车</a></button></th>        
                        <th><button type="submit">下单结算</button></th> 
                      </tr>
                    </thead>
                    <script type="text/javascript">

                        $('#clearCar').click(function() { 
                          
                        });
                    </script>
                  </table>
                </div>
              </div>
              <div class="member-mod-title">
                <h2>最近的订单</h2>
                <span>
                  <a href="/member-orders.html">查看所有订单 </a>
                </span>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
@else
 <div id="container" class="page-container clearfix">
      <div class="wrap">
        <div class="bread-crumbs"></div>
        <div id="main">
          <!-- 购物车开始 -->
          <div class="cart-title">
            <h1>
            <i class="icon">&lt;</i>购物车</h1>
          </div>
          <div class="cart-empty">
          <q class="icon">=</q> 
          <q class="empty-tip">
          <b>您的购物车里还没有商品</b>，您可以：
          <br />将
          <a href="/">收藏夹</a>中的商品添加进来，或者去看看 
          <a href="/">商城 ?</a></q></div>
          <!-- 浏览过的商品 -->
          <div id="view_history" class="view-history">
            <div class="title">浏览过的商品
            <!--  <a href="javascript:void(0);" id="clear_history">清除</a> --></div>
            <div class="content">
              <ul class="history-list"></ul>
            </div>
          </div>
        </div>
      </div>
    </div>
@endif
@endsection